/*---------------------------------------------------------*/
/* User Provided RTC Function for FatFs module             */
/*---------------------------------------------------------*/
/* This is a real time clock service to be called from     */
/* FatFs module. Any valid time must be returned even if   */
/* the system does not support an RTC.                     */
/* This function is not required in read-only cfg.         */

#include "lpc177x_8x_rtc.h"
#include "integer.h"
DWORD get_fattime (void)
{
	RTC_TIME_Type rtc;

	/* Get local time */
	RTC_GetFullTime(LPC_RTC, &rtc);

	/* Pack date and time into a DWORD variable */
	return	  ((DWORD)(rtc.YEAR - 1980) << 25)
			| ((DWORD)rtc.MONTH << 21)
			| ((DWORD)rtc.DOM << 16)
			| ((DWORD)rtc.HOUR << 11)
			| ((DWORD)rtc.MIN << 5)
			| ((DWORD)rtc.SEC >> 1);
}

